import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2023-08-25
 * Time: 10:04
 */
public class Test1 {
    public static void main(String[] args) {
        TestHeap testHeap1=new TestHeap();
        int[] array={27,15,19,18,28,34,65,49,25,37};
        testHeap1.createHeap(array);
        System.out.println(testHeap1);

        testHeap1.push(90);
        System.out.println(testHeap1);

        testHeap1.poll();
        System.out.println(testHeap1);

        testHeap1.heapSort();
        System.out.println(testHeap1);

    }
}

class Sort{
    public static void insertSort(int[] array ){
        for (int i =1; i < array.length; i++) {
            int temp=array[i];//记录当前的元素，准备随时插入，同时放置元素被覆盖掉
            int j=i-1;
            for (; j>=0; j--) {
                if(array[j]>temp){
                    //当前j下标的元素后移
                    array[j+1]=array[j];
                }else{
                    break;
                }
            }
            array[j+1]=temp;//没有j下标的元素大，插入它的后面
        }
    }

    public static void main(String[] args) {
        int[] array=new int[]{5,4,3,2,1};
        insertSort(array);
        System.out.println(Arrays.toString(array));
    }
}
